package com.daotingli.backendprograms.Controller.Admin.Authoer;


import com.daotingli.backendprograms.Service.Admin.Authoer.AuthoerService;
import com.daotingli.backendprograms.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
public class AuthoerController {
    @Autowired
    private AuthoerService authoerService;


    @RequestMapping(path = "/admin/author/getAll",method = RequestMethod.POST)
    public Result getAllAuthoers()
    {
        return authoerService.getAllAuthoers();
    }
    @RequestMapping(path = "/admin/author/add",
            method = RequestMethod.POST,
            params = {"username","password","identity","userphone","userstate"})
    public Result addAuthoer(@RequestParam("username") String username,
                            @RequestParam("password") String password,
                            @RequestParam("identity") String identity,
                            @RequestParam("userphone") String userphone,
                            @RequestParam("userstate") String userstate){
        return authoerService.addAuthoer(username,password,identity,userphone,userstate);
    }
    @RequestMapping(path = "/admin/author/delete",
            method = RequestMethod.POST,
            params = {"id"})
    public Result deleteAuthoer(@RequestParam("id") Integer id){
        return authoerService.deleteAuthoer(id);
    }
    @RequestMapping(path = "/admin/author/update",
            method = RequestMethod.POST,
            params = {"id","username","password","identity","userphone","userstate"})

    public Result updateAuthoer(@RequestParam("id") Integer id,
                               @RequestParam("username") String username,
                               @RequestParam("password") String password,
                               @RequestParam("identity") String identity,
                               @RequestParam("userphone") String userphone,
                               @RequestParam("userstate") String userstate){
        return authoerService.updateAuthoer(id,username,password,identity,userphone,userstate);

    }
}
